package post_type

import (
	"github.com/gin-gonic/gin"
	. "myplatform/handler"
	"myplatform/libs/errcode"
	"myplatform/model"
	"strconv"
)

// 根据类型找post
func GetPostBytype(c *gin.Context) {
	id, err := strconv.Atoi(c.Query("id"))
	if err != nil {
		SendRsp(c, errcode.ParamTypeError, nil)
		return
	}
	var t model.PostType
	t.Ip = uint64(id)
	if err := t.GetPostByType(); err != nil {
		SendRsp(c, errcode.SearchError, err)
		return
	}
	SendRsp(c, errcode.OK, t.Posts)
}

func GetPostBytypeHTML(c *gin.Context) {
	c.HTML(200, "type_post.html", gin.H{})
}
